//删除有序数组中的重复项
//输入：nums = [0,0,1,1,1,2,2,3,3,4]
//输出：5, nums = [0,1,2,3,4]
class Solution2 {
    public int removeDuplicates(int[] nums) {
        if(nums.length == 0){
            return 0;
        }
        //定义快慢指针slow为慢指针,fast为快指针
        int slow = 1;
        for(int fast = 1;fast<nums.length;fast++){
            if(nums[fast] != nums[slow-1]){
                nums[slow] = nums[fast];
                slow++;
            }
        }
        return slow;
    }
}